package cn.edu.neusoft.maxingxin231.yuejian06.Fragment.Club;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Activity.MainActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.ClubAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.ClubBean;
import cn.edu.neusoft.maxingxin231.yuejian06.Listener.ListListener;
import cn.edu.neusoft.maxingxin231.yuejian06.Model.ClubModel;
import cn.edu.neusoft.maxingxin231.yuejian06.R;

/**
 * A simple {@link Fragment} subclass.

 */
public class ClubDistanceFragment extends Fragment {
    private View view = null;
    private Context context;
    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private ClubAdapter clubAdapter;
    private List<ClubBean> items = null;
    String userid;

    ListListener<ClubBean> clubBeanListListener = new ListListener<ClubBean>() {
        @Override
        public void onResponse(List<ClubBean> list) {
            //Toast.makeText(context, "success", Toast.LENGTH_SHORT).show();
            items = list;
            clubAdapter.setList(list);
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context, "11" + msg, Toast.LENGTH_SHORT).show();
        }
    };

//    @Override
//    public void onResume() {
//        super.onResume();
//        ClubModel allCollectModel = new ClubModel();
//        allCollectModel.getClubList(userid, "0", clubBeanListListener);
//
//    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        context = getActivity();
        view = inflater.inflate(R.layout.fragment_club_distance,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        layoutManager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);
        clubAdapter = new ClubAdapter(getActivity(),items,R.layout.club_card);
        clubAdapter.setList(items);
        // Inflate the layout for this fragment
       recyclerView.setAdapter(clubAdapter);
        ClubModel clubModel = new ClubModel();
        clubModel.getClubList(clubBeanListListener);


       return view;
        //return inflater.inflate(R.layout.fragment_club_distance, container, false);
    }


}
